package com.menu;

import com.company.TreeCRUD;

import java.io.IOException;
import java.util.Scanner;

public class TreeServerMenu {

    public void treeServerMenu() throws IOException {

        System.out.println("平衡二叉树服务菜单");

        TreeCRUD tCRUD = new TreeCRUD();

        boolean flag = true;
        while (flag){

            System.out.println("\\n请选择服务的种类：\\n");
            System.out.println("\t1.平衡二叉树读取文件");
            System.out.println("\t2.平衡二叉树添加道路");
            System.out.println("\t3.平衡二叉树查询道路信息");
            System.out.println("\t4.平衡二叉树修改信息");
            System.out.println("\t5.平衡二叉树删除信息");
            System.out.println("\t6.转顺序表存储");
            System.out.println("\t7.转链表存储");
            System.out.println("\t0.退出");
            System.out.print("\t请选择：");

            int sc = -1;
            try{
                Scanner scanner = new Scanner(System.in);
                sc = scanner.nextInt();
            }catch (Exception e) {
                System.out.println("错误有误,请重新输入");
            }
            switch (sc){
                case 1:{
                    tCRUD.treeReadFilePrint();
                    break;
                }
                case 2:{
                    tCRUD.treeInsert();
                    break;
                }
                case 3:{
                    tCRUD.treeSerch();
                    break;
                }
                case 4:{
                    tCRUD.treeUpdate();
                    break;
                }
                case 5:{
                    tCRUD.treedDelete();
                    break;
                }
                case 6:{
                    ArrayServerMenu sm = new ArrayServerMenu();
                    sm.serverMenu();
                    break;
                }
                case 7:{
                    LinkServerMenu lsm = new LinkServerMenu();
                    lsm.linkServerMenu();
                    break;
                }
                case 0:{
                    flag = false;
                    break;
                }
                default:{
                    System.out.println("输入有误，请重新输入：");
                    break;
                }
            }
        }


    }

}
